package com.newbsd.web.maventest.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.newbsd.web.maventest.service.UserService;
import com.newbsd.web.maventest.service.impl.UserServiceImpl;

/**
 * @author Mei
 */
@WebServlet("/delUserServlet")
public class delUserServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public delUserServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		doPost(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		
		Integer userid = Integer.parseInt(request.getParameter("userid"));
		System.out.println(userid);
		UserService userService = new UserServiceImpl();
		userService.delUser(userid);
		response.getWriter().append(JSON.toJSONString(userid));
	}

}
